import { Entity, Column, PrimaryGeneratedColumn, UpdateDateColumn, ManyToOne, JoinColumn } from 'typeorm';
import { ApiProperty} from '@nestjs/swagger';
import { Exclude } from "class-transformer";
import {
  IsOptional,
  IsString,
  MaxLength,
  MinLength,
  IsNotEmpty,
  IsEmail,
  IsPhoneNumber,
  IsMobilePhone,
  IsDate,
  ValidateNested, IsDateString
} from "class-validator";
import { Coupon } from './coupon.entity';
import { Goods } from './goods.entity';

@Entity()
export class CouponGoods {
  @PrimaryGeneratedColumn({type: 'int'})
  id: number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int' , nullable: false})
  coupon_id:number;

  @IsOptional()
  @ApiProperty()
  @Column({type: 'int', nullable: false})
  goods_id:number;

  @ManyToOne(type => Coupon, coupon => coupon.couponGoods)
  @JoinColumn({
    name:"coupon_id"
  })
  coupon:Coupon

  @ManyToOne(type => Goods, goods => goods.couponGoods)
  @JoinColumn({
    name:"goods_id"
  })
  goods:Goods
}
